<?php
$arr = array('2','.1','2.', '5.10', '.', '');
foreach ($arr as $value) {
    //var_dump($value, is_numeric($value), floatval($value));
    //echo "<br/>";
}

var_dump(sprintf("%d", 2.583), sprintf("%5d", 2.583));

var_dump((int)$arr);exit;

//匹配数字
$numberPattern = '/^\s*[-+]?([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)+([eE][-+]?[0-9]+)?\s*$/';
foreach ($arr as $value) {
    $message = true;
    if(!preg_match($numberPattern,"$value"))
    {
        $message = false;
    }
     var_dump($value, $message, floatval($value));
     echo "<br/>";
}